﻿//-------------------------------------------------------------------------------------------
// <copyright file="AccountInfoViewModel.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.TestClient.ViewModels
{
    using Ripple.Data;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;

    /// <summary>
    /// TODO: Describe the class
    /// </summary>
    public class AccountInfoViewModel : ViewModel<Account>
    {
        public static readonly DependencyProperty AccountIdProperty = DependencyProperty.Register("AccountId", typeof(string), typeof(AccountInfoViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty BalanceProperty = DependencyProperty.Register("Balance", typeof(long), typeof(AccountInfoViewModel), new PropertyMetadata((long)0));
        public static readonly DependencyProperty NextTransactionSequenceProperty = DependencyProperty.Register("NextTransactionSequence", typeof(int), typeof(AccountInfoViewModel), new PropertyMetadata(0));
        public static readonly DependencyProperty OwnerCountProperty = DependencyProperty.Register("OwnerCount", typeof(int), typeof(AccountInfoViewModel), new PropertyMetadata(0));
        public static readonly DependencyProperty PreviousTransactionIdProperty = DependencyProperty.Register("PreviousTransactionId", typeof(String), typeof(AccountInfoViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty UpdatedProperty = DependencyProperty.Register("Updated", typeof(DateTime), typeof(AccountInfoViewModel));

        /// <summary>
        /// Initializes a new instance of the AccountInfoViewModel class.
        /// </summary>
        public AccountInfoViewModel(Account model)
        {
            this.Model = model;
        }

        public string AccountId
        {
            get { return (string)GetValue(AccountIdProperty); }
            set { SetValue(AccountIdProperty, value); }
        }

        public long Balance
        {
            get { return (long)GetValue(BalanceProperty); }
            set { SetValue(BalanceProperty, value); }
        }

        public int NextTransactionSequence
        {
            get { return (int)GetValue(NextTransactionSequenceProperty); }
            set { SetValue(NextTransactionSequenceProperty, value); }
        }

        public int OwnerCount
        {
            get { return (int)GetValue(OwnerCountProperty); }
            set { SetValue(OwnerCountProperty, value); }
        }

        public String PreviousTransactionId
        {
            get { return (String)GetValue(PreviousTransactionIdProperty); }
            set { SetValue(PreviousTransactionIdProperty, value); }
        }

        public DateTime Updated
        {
            get { return (DateTime)GetValue(UpdatedProperty); }
            set { SetValue(UpdatedProperty, value); }
        }

        protected override void RefreshData()
        {
            this.AccountId = this.Model.Id;
            this.Balance = this.Model.Balance;
            this.PreviousTransactionId = this.Model.PreviousTransactionId;
            this.OwnerCount = this.Model.OwnerCount;
            this.NextTransactionSequence = this.Model.NextTransactionSequenceNumber;
            this.Updated = this.Model.Updated;
        }
    }
}